﻿using Assets.Scripts.UI;
using System.Collections;
using UnityEngine;

namespace Assets.Scripts.System.GameState
{
    public class GamingState : IState<global::GameState>
    {
        public void OnEnter(global::GameState fromStateType)
        {
            UIManager.Instance.PushPanel(UIPanelType.GamingPanel);
            SoundSystem.Instance.PlayBGM("10007");
        }

        public void OnExit(global::GameState toStateType)
        {
            if (UIManager.Instance.GetTopPanel().GetPanelType() == UIPanelType.GamingPanel)
            {
                UIManager.Instance.PopPanel();
            }
        }

        public void OnUpdate()
        {
            if (MapSystem.Instance.isOpen)
            {
                MapSystem.Instance.OnUpdate();
            }
            if (Input.GetKeyDown(KeyCode.Escape))
            {
                GameManager.Instance.TranslateGameState(global::GameState.Pausing);
            }
            if (Input.GetKeyDown(KeyCode.BackQuote))
            {
                GameManager.Instance.TranslateGameState(global::GameState.CMD);
            }
        }
    }
}